import Vue from "vue"
import VueRouter from "vue-router"

//将路由注入所有子组件中
Vue.use(VueRouter)

//声明路由配置 Routes
let routes = [
    {
        path:"/discover",
        //路由懒加载，(按需加载)，主要通过import()这种语法，vue-cli是基于webpack、webpack编译的时候，遇到import()这种语法，就会自动将代码进行分割，split-code，实现懒加载的核心就是使用webpack的代码分割功能
        //懒加载的好处：提高首屏的加载速度，提升用户体验，节省流量
        component: () => import(/*webpackChunkName:'discover*/"@/pages/discover" )
    },
    {
        path:"/friend/:wq",
        component: () => import (/*webpackChunkName:'friend*/"@/pages/friend" )
    },
    {
        path:"/mine",
        component: () => import ( /*webpackChunkName:'mine*/"@/pages/mine" )
    },
    {
        path:"/list",
        component: () => import ( /*webpackChunkName:'list*/"@/pages/list" )
    },
    {
        path:"/detail/:productid",
        component: () => import ( /*webpackChunkName:'detail*/"@/pages/detail" )
    },
];

//实例化路由
let router = new VueRouter({
    routes
});

// 把路由导出去
export default router;
